#pragma once

#include <map>

#include "memdb/memdb.h"

namespace memdb {
namespace impl {
namespace mock {

class MockTable : public memdb::ITable{
public:
  MockTable();
  ~MockTable() override;

  std::error_code get(const KeyType & key, ValueType & value) const override ;
  std::error_code insert(const KeyType & key, const ValueType & value) override ;
  std::error_code remove(const KeyType & key) override ;

  std::error_code update(const KeyType & key, const ValueType & value) override ;
  std::error_code replace(const KeyType & key, const ValueType & value) override ;
  std::error_code update(const KeyType & key, const ValueType & value, ValueType & old) override ;
  std::pair<std::error_code, bool> replace(const KeyType & key, const ValueType & value, ValueType & old) override ;

  size_t count() const override;

  std::unique_ptr<Iterator> iterator() const override;
  std::unique_ptr<Iterator> range(size_t index, size_t len) const override;
  std::unique_ptr<Iterator> findRange(const KeyType & key, size_t offset, size_t len) const override;

private:
  std::map<KeyType, ValueType> _records;      
};

}//namespace mock
}//namespace impl
}//namespace memdb
